#!/bin/bash
tmppatha=/tmp/pathtmpa
tmppathb=/tmp/pathtmpb
if [ "$#" -ne "1" ]
      then
    echo "useage:`basename $0` [path]"
    exit 1
else
    cd $1 &> /dev/null ||{
echo "option [path] is not a real path ! "
    exit 1
    }
if [ -e $tmppatha ]
      then
    if [ -s $tmppatha ]
    then
    for i in `find . -type f `
    do
        md5sum $i >> $tmppathb
    done

    diff $tmppathb $tmppatha > /tmp/pathfilec
    if [ -s /tmp/pathfilec ]
    then
        echo "[Wroning:] $1 has been modify! : `date +%Y-%m-%d_%H:%M`"
        echo "modify file list :"
     for i in `cat /tmp/pathfilec | grep '^<'|awk '{print $3}'`
     do
         echo -n FILE: $i
         echo -n " "
         echo -n MODIFY_TIME: `stat $i|grep 'Modify'|awk '{printf("%s %sn",$2,$3)}'`
         echo
     done

        rm -rf $tmppathb
    else
        rm -rf $tmppathb
    fi
        rm -rf /tmp/pathfilec &> /dev/null
    fi
else
    echo "pathtmp init"
    for i in `find . -type f `
    do
        md5sum $i >> $tmppatha
    done
    echo "pathtmp init ok!~"
    echo "run twice to start cheak!"
fi
fi